package com.boarsoft.elasticsearch;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import org.elasticsearch.client.transport.TransportClient;

public interface ElasticSearchClient {
	/**
	 * 
	 * @param index
	 * @param type
	 * @param id
	 * @return
	 */
	String get(String index, String type, String id);

	/**
	 * 日志超时时间，单位毫秒
	 * 
	 * @param index
	 * @param type
	 * @param id
	 * @param m
	 * @param timeout
	 * @param unit
	 * @return
	 */
	String save(String index, String type, String id, Map<String, String> m, long timeout, TimeUnit unit);

	/**
	 * 
	 * @return
	 */
	TransportClient getClient();

	/**
	 * 
	 * @param index
	 * @param type
	 * @param lt
	 * @param timeout
	 * @param timeUnit
	 * @throws Exception
	 */
	void bulkSave(String index, String type, List<Map<String, Object>> lt, long timeout, TimeUnit timeUnit) throws Exception;

	/**
	 * 清除某个index中的所有数据
	 * 
	 * @param index
	 * @throws ExecutionException
	 * @throws InterruptedException
	 */
	void truncate(String index) throws InterruptedException, ExecutionException;

	/**
	 * 
	 * @param index
	 * @param id
	 * @throws ExecutionException 
	 * @throws InterruptedException 
	 */
	void delete(String index, String id) throws InterruptedException, ExecutionException;
}
